/*	
	Unwrap plugin for jQuery
	Version: 1.2

	Copyright (c) 2009 Todd Northrop
	http://www.speednet.biz/
	
	December 11, 2009

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------*/

jQuery.fn.unwrap = function () {
	///	<summary>
	///		Removes the immediate parent wrapping element from each element of the matched set.
	/// 	For elements in the matched set that share a common parent, the common parent element
	/// 	is removed.
	///	</summary>
	///	<returns type="jQuery">
	///		Returns the original jQuery matched set.
	/// </returns>
	/// <remarks>
	/// 	To keep things simple, I have avoided adding a selector argument to this extension.
	/// 	I suppose I could add it, but perhaps that is best done with a .filter() before
	/// 	calling .unwrap(). If you have an opinion about this, let me know.
	/// 	
	/// 	New for version 1.1, elements in the wrapped set that are direct children of the
	/// 	body tag will not be unwrapped, because doing so would delete the body tag.
	/// </remarks>
	
	return this.parent(":not(body)").each(
		function () {
			var $set = jQuery(this);
			$set.replaceWith($set.contents());
		}
	).end();
};

jQuery.fn.unwrapInner = function () {
	///	<summary>
	///		Replaces each element in the matched set with the element's inner contents. If an
	/// 	element does not have any contents, it is simply removed.
	///	</summary>
	///	<returns type="jQuery">
	///		Returns the original jQuery matched set.
	/// </returns>
	
	return this.each(
		function () {
			var $set = jQuery(this);
			$set.replaceWith($set.contents());
		}
	).end();
};

